package com.mall.order.controller;

import com.mall.api.order.OrderFeignClient;
import com.mall.api.order.dto.OrderDTO;
import com.mall.common.result.Result;
import com.mall.order.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class OrderController implements OrderFeignClient {

    private final OrderService orderService;

    @Override
    public Result<OrderDTO> createOrder(OrderDTO orderDTO) {
        return Result.success(orderService.createOrder(orderDTO));
    }

    @Override
    public Result<OrderDTO> getOrderById(Long id) {
        return Result.success(orderService.getOrderById(id));
    }

    @Override
    public Result<OrderDTO> getOrderByUserId(Long userId) {
        return Result.success(orderService.getOrderByUserId(userId));
    }

    @Override
    public Result<Void> updateOrderStatus(Long id, Integer status) {
        orderService.updateOrderStatus(id, status);
        return Result.success();
    }

    @Override
    public Result<Void> deleteOrder(Long id) {
        orderService.deleteOrder(id);
        return Result.success();
    }
} 